home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Univers Interactif 3
/
INTERACTIF.BIN
/
pc
/
planeten
/
internet
/
macslip2.6up
/
MacSLIP Folder
/
Netblazer.script
< prev
next >
Wrap
Text File
|
1995-01-11
|
7KB
|
291 lines
#
# Netblazer.script
#
# Script for a Netblazer terminal server
# You may need to modify it to work with your particular configuration.
#
# This script is designed to dial a Hayes compatible modem.
#
# The first time this script runs, it will prompt for your username,
# password, and phone number to dial. These settings will be saved
# for subequent connections.
#
# Using default settings, the modem will be initialized before this script
# starts running. Make sure the "Init modem when connecting" option
# is set in the "Modem" menu and that you have made an appropriate
# modem selection.
#
ignore var busygo
# If user is not defined, ask for it.
ifdef user goto skipuser
message ""
message "\bEnter your login username."
ask var
define user "$var"
label skipuser
# if password is not defined, ask for it
ifdef password goto skippass
message "Will login to SLIP server as $user.\n\bPassword:"
askp var
define /h password "$var"
label skippass
# if phone is not defined, ask for it
ifdef phone goto skipphone
message "\bEnter the phone number to dial"
ask var
define phone "$var"
label skipphone
# Let the user know we're starting up
label startup
message "Script starting..."
# Setup action handlers
on restart goto restart
on abort goto abort
# Dial the phone and wait for the terminal server to send its login
# banner. Some areas support using *70 as a dialing prefix to suppress
# call-waiting tones which will probably cause your modem
# to lose the connection. Some terminal servers may require you to
# autobaud before they will respond. Allow enough time for the modem
# handshake to complete.
label dial
ifdef INITMODEM goto skipwarn
beep
message "\bYou should select a modem using Configure"
label skipwarn
message "Dialing $phone..."
flush
on abort goto hangupabort
send "ATDT $phone\r"
{
ifmatch "name:" break
ifmatch "Login:" break
ifmatch "login:" break
ifmatch "NO DIALTONE" goto nodialtone
ifmatch "NO DIAL TONE" goto nodialtone
ifmatch "BUSY" goto phonebusy
ifmatch "NO CARRIER" goto nocarrier
iftime 1:15 goto dialtimeout
}
# Log into the SLIP server. Try three times to send the username. Use
# counter #1 to count the number of login attempts.
setcount 1 0
label login
ifcountgt 1 3 goto cantlogin
message "Logging in as $user..."
setcount 0 0
label user
flush
ifcountgt 0 3 goto baduser
send "$user\r"
{
ifmatch "Password:" break
ifmatch "password:" break
ifmatch "Username:" goto user
ifmatch "login:" goto user
ifmatch "Login:" goto user
iftime 10 goto baduser
}
# Send the password and wait for the prompt. If we see the
# username prompt again, then we didn't get logged in so try again.
message "Sending password..."
flush
send "$password\r"
{
ifmatch ">" goto setslip
ifmatch "%" goto setslip
ifmatch "Access denied" goto accessdenied
ifmatch "incorrect" goto accessdenied
iftime 10 goto cantlogin
}
# If the login attempt fails, we land here.
label accessdenied
{
ifmatch "Username:" goto login
ifmatch "Login:" goto login
ifmatch "login:" goto login
ifmatch "NO CARRIER" goto cantlogin
iftime 10 goto cantlogin
}
# Enable SLIP.
label setslip
message "Enabling SLIP mode on server..."
flush
send "slip\r"
{
ifmatch "connected" break
ifmatch "Connected" break
iftime 10 goto cantstartslip
}
# All done. Send message to alert the user, flush the junk out of the
# receive buffer, and return success.
message "Script complete"
flush
return 1
# Error handlers.
label abort
beep
message "\bCommand-. seen or Cancel button clicked."
goto aborted
label hangupabort
beep
message "\bCommand-. seen or Cancel button clicked."
goto hangup
label cantfindmodem
beep
message "\bThe modem didn't respond to attention"
message "\bbsignal. Check modem and cabling."
goto aborted
label cantinitmodem
beep
message "\bThe modem didn't respond to initialization"
message "\bstring. Check the modem."
goto aborted
label nodialtone
beep
message "\bThe modem could not detect a dialtone."
message "\bCheck the phone line."
goto aborted
label phonebusy
flush
message "\bThe number $phone is busy."
if $busygo eq "go" goto redial
on restart goto busygo
beep
message "\bClick "Restart" to keep trying, "OK" to quit."
ask junk
return 0
label busygo
on restart goto restart
set busygo "go"
flush
label redial
do syncmodem
goto dial
label nocarrier
beep
message "\bThe modem could not establish a connection."
message "\bMake sure there is a modem on the other end."
goto aborted
label dialtimeout
message "\bThe modem or SLIP server isn't responding."
message "\bTry dialing manually to make sure the modem"
message "\band SLIP server are OK."
goto aborted
label baduser
beep
message "\bThe SLIP server won't accept a username."
message "\bTry dialing manually to make sure the SLIP"
message "\bserver is OK."
goto hangup
label cantlogin
beep
message "\bLogin to SLIP server failed, check username"
message "\band password."
goto hangup
label cantsetterm
beep
message "\bCan't set terminal line for SLIP operation."
goto hangup
label cantstartslip
beep
message "\bCan't put server into SLIP mode."
goto hangup
# General back-end for bailing out.
label hangup
do disconnect
# fallthrough into aborted
label aborted
message "\bScript aborted!"
message "\bClick "OK" to quit, "Restart" to retry."
# This activates the OK button.
ask junk
flush
return 0
# Restart procedure.
# This label is entered when you click the restart button in the
# connection dialog. We try to force the modem to hang up, then we go back
# to the start of the script.
label restart
do disconnect
message "\bScript restarted."
goto startup
# Disconnect procedure. The "disconect" procedure is called by MacSLIP
# when the "Disconnect" button is clicked. This procedure escapes the
# modem into command mode and hangs up the phone. The +++ escape sequence
# is surrounded by delays that some modems require.
label disconnect
send "\d\d+++\d\dATH\r\d\d"
do syncmodem
return 1
# Alternate disconnect procedure for modems that drop into command mode
# when DTR is dropped. You may want to try this alternate disconnect
# procedure if the one above doesn't work for your modem. Just swap the
# labels to use this one instead of the one above.
label disconnect2
dtr off
delay 3
send "ATH\r"
dtr on
flush
return 1
# Attempt to sync up with the modem, but don't wait forever.
label syncmodem
setcount 4 0
flush
label waitmodem2
ifcountgt 4 2 return
send "AT\r"
{
ifmatch "OK" break
iftime 2 goto waitmodem2
}
flush
return
# for Emacs
# Local Variables:
# tab-width: 4
# End: